package com.hospital.data.simulation.controller;

import com.hospital.common.base.Result;
import com.hospital.common.pojo.TDepartment;
import com.hospital.data.simulation.service.TDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 科室管理接口
 * <br>
 * 科室增删改方法:addDepartment, deleteDepartment, updateDepartment
 * @author yhn
 * @version 1.0
 */
@RestController
@RequestMapping("/department")
public class DepartmentController {
    @Autowired
    private TDepartmentService departmentService;

    /**
     * 添加科室
     */
    @PostMapping("/add")
    public Result<Long> addDepartment(@RequestBody TDepartment department) {
        return Result.success(departmentService.addDepartment(department));
    }
    /**
     * 删除科室
     */
    @DeleteMapping("/delete")
    public Result<?> deleteDepartment(@RequestParam("id") Integer id) {
        departmentService.deleteDepartment(id);
        return Result.success();
    }
    /**
     * 修改科室
     * <br>
     * 需要提供科室id
     */
    @PostMapping("/update")
    public Result<?> updateDepartment(@RequestBody TDepartment department) {
        departmentService.updateDepartment(department);
        return Result.success();
    }
}
